package com.sinosoft.svc.util;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import smsmessage.sms.SMSclientSubmit;


public final class SDUtils {

	private static Logger logger = Logger.getLogger(SDUtils.class);


	public static String sendMessage(String phone,String message){
		synchronized (RCUtils.class) {
		//SmsClient.getInstance();//建立连接
		SMSclientSubmit mt = new SMSclientSubmit();///实例化用于下发短信的对象
		mt.setDestID(phone);//接收号码
		mt.setPriority(1);// 设置优先级，默认为1
		mt.setMsgContent(message);// 短信内容
		List<String> sendIDList = new ArrayList<String>();
		sendIDList = mt.sendSMSList();
		String errorMessage = "true";
		for(String sendList:sendIDList){
			switch(sendList){
				case"1":
					logger.error("信息下发缓冲队列已满");
					errorMessage = "信息下发缓冲队列已满";
					break;
				case"2":
					logger.error("没有建立连接");
					errorMessage = "没有建立连接";
					break;
				case"3":
					logger.error("流量超出设定值");
					errorMessage = "流量超出设定值";
					break;
				case"4":
					logger.error("短信长度超出限制");
					errorMessage = "短信长度超出限制";
					break;
				case"5":
					logger.error("群发数量超出");
					errorMessage = "群发数量超出";
					break;
				case"6":
					logger.error("分隔符不正确");
					errorMessage = "分隔符不正确";
					break;
			}
		}
		RCUtils.class.notify();
		return errorMessage;
		}
	}
	
}
